<?php
namespace app\common\business;


class GoodsSku extends BusBase {
    public $model = null;

    public function __construct()
    {
        $this->model = new \app\common\model\mysql\SpecsValue();
    }

    public function getNormalSkuAndGoods($id){
        try {
            $result = $this->model->with('goods')->find($id);
        } catch (\Exception $e) {
            return [];
        }
        if (empty($result)){
            return [];
        }
        $result = $result->toArray();
        if ($result['status'] != config('status.mysql.table_normal')){
            return [];
        }
        return $result;
    }

    public function getSkusByGoodsId($goodsId = 0){
        if (empty($goodsId)){
            return [];
        }
        try {
            $skus = $this->model->getNormalByGoodsId($goodsId);
        } catch (\Exception $e) {
            return [];
        }
        return $skus->toArray();
    }
}